package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsName   string  `gorm:"type:varchar(256);not null;comment:'商品名称'"`
	GoodsPrice  float64 `gorm:"type:decimal(10,2);not null;comment:'商品价格'"`
	GoodsNum    int     `gorm:"type:int(200);not null;comment:'商品库存'"`
	GoodsStatus int     `gorm:"type:tinyint(1);default:1;not null;comment:'商品状态:1-已上架,2-未上架'"`
}

type User struct {
	gorm.Model
	UserName string `gorm:"type:varchar(10);not null;comment:'用户名称'"`
	PassWord string `gorm:"type:varchar(20);not null;comment:'用户密码'"`
}

func NewGoods() *Goods {
	return &Goods{}
}

func (g *Goods) GetDetail(id int) error {
	return DB.Where("id=?", id).First(&g).Error
}
